﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

//importamos
using EventSys.BussinesEntities;

namespace EventSys.Repository
{
    public class UbigeoRepository:MasterRepository,IUbigeoRepository
    {
        public List<Ubigeo> listarPaises(string idPais)
        {
            var query = (from p in Context.Ubigeos
                         where p.idUbigeo.StartsWith(idPais) && p.Nivel.Contains("Pais")
                         orderby p.Nombre
                         select p);

            return query.ToList();
        }

        public List<Ubigeo> ListProvinciaByDepartamento(string idDepartamento)
        {
            var query = (from d in Context.Ubigeos
                         where d.idUbigeo.StartsWith(idDepartamento) && d.Nivel.Contains("Provincia")
                         orderby d.Nombre
                         select d);

            return query.ToList();
        }

        public List<Ubigeo> ListDepartamentoByPais(string idPais)
        {
            var query = (from p in Context.Ubigeos
                         where p.idUbigeo.StartsWith(idPais) && p.Nivel.Contains("Departamento")
                         orderby p.Nombre
                         select p);

            return query.ToList();

        }

        public List<Ubigeo> ListHijosByIdUbigeoR(string idUbigeoR)
        {
            var query = (from p in Context.Ubigeos
                         where p.idUbigeoR.Equals(idUbigeoR)
                         orderby p.Nombre
                         select p);

            return query.ToList();
        }

    }
}
